import {
	isIOS,
	isWeixin,
	isqq,
	isAndroid,
	isHuwei,
	flvCommon,
	hasClass,
	toggleClass,
	addClass,
	removeClass
} from './common/utils'
import EventEmitter from './common/EventEmitter'
import {playerEvents} from './playerEvents'
import './styles/fullscreenPlayer.scss'
const Base64 = window.Base64
const flv = window.flvjs
function loadInitLine(serverUrl,flvSupport){
 	var urlArr = [];
	if(flvSupport){
		serverUrl.forEach((item,index)=>{
			if(item.flv && typeof(item.flv) === 'string'){
				item.flv = Base64.decode(item.flv)
				urlArr.push(item.flv)
			}
		})
	}else{
		serverUrl.forEach((item,index)=>{
			item.hls = Base64.decode(item.hls)
			urlArr.push(item.hls)
		})
	}
 	return {urlArr,serverUrl};
}
function wxPlayVideo(video) {
	WeixinJSBridge.invoke('getNetworkType', {}, function(e) {
		video.play().catch(err => {
			console.log(err)
		});
	});
}

function playAuto() {
	var self = this;
	self.play().catch(err => {
		console.log(err)
	});
	document.querySelector('.fullscreen-video-load').style.display = 'block'
	if (isWeixin) {
		var evtFns = [];
		try {
			wxPlayVideo(self);
			return;
		} catch (ex) {
			evtFns.push("WeixinJSBridgeReady", function evt() {
				wxPlayVideo(self);
				for (var i = 0; i < evtFns.length; i += 2) document.removeEventListener(evtFns[i], evtFns[i + 1], false);
			});
			document.addEventListener("WeixinJSBridgeReady", evtFns[evtFns.length - 1], false);
		}
	}
}
HTMLVideoElement.prototype.playAuto = playAuto;
export default class fullScreenPlayer {
	//视频开始卡顿时间
	static emptyTime = 0;
	//视频加载好后开始播放的时间
	static fullTime = 0;
	//在发送时间内视频卡顿的时间
	static totalTime = 0;
	static sendTimer = null;
	static videoControlTimer = null;
	constructor() {
		let args = arguments[0]
		let defaultConfig = {sendTime:10}
		Object.assign(defaultConfig,args)
		for (var i in defaultConfig) {
			this[i] = defaultConfig[i]; //一种快捷的初始化配置
		}
		this.init();
	}
	init() {
		if(!this.openHls){
			this.flvSupport = flvCommon.flvSupport
		}else{
			this.flvSupport = false
		}
		let obj = loadInitLine(this.watchServer,this.flvSupport)
		this.autoChange = true
		this.autoPlay = true
		this.watchServer = obj.serverUrl
		this.urlArr = obj.urlArr
		this.hlsUrl = obj.urlArr[0]
		if(typeof(this.el) === 'string' && document.getElementById(this.el)){
			this.el = document.getElementById(this.el)
		}else{
			console.error('el参数为元素ID,该参数必传!')
		}
		let that = this
		this.emitter = new EventEmitter()
		HTMLVideoElement.prototype.playAuto = playAuto
		this.currentHlsIndex = this.findCurrentUrlIndex(this.hlsUrl)
		Promise.resolve().then(() => {
			this.emitter.trigger(playerEvents.SET_PLAYER_INDEX, this.currentHlsIndex)
		})
		if (this.mode === 0) {
			this.el.innerHTML =
				'<div class="fullscreen-player-wrap fullscreen-player-wrap-mode0"><div class="fullscreen-play-btn">\
					<div class="player_btn_bg"></div>\
					<p>正在直播中，戳这里看直播。</p>\
				</div>\
				<div class="choose-line-wrap"><div class="choose-line-innerwrap fl fix" style="display:none"><div class="choose-line-inner-leftwrap fl">线路选择  :</div><div class="choose-line-inner-rightwrap fr"><span class="line-name">'+this.watchServer[this.currentHlsIndex].name +'</span><i class="choose-line-icon"></i></div></div><div class="set-auto-change-wrap fr" style="display:none"><a href="javascript:;" class="mode0-auto-change-span">关闭自动切换流</a></div></div>\
				<div class="flv-error-tips" style="display:none">当前flv无法播放,正在帮您切换,请稍等</div>\
				<p class="fullscreen-line-load" style="display:none">当前流不稳定,正在帮您切换线路,请亲们耐心等待...</p>\
				<p class="fullscreen-video-load" style="display:none">视频加载中,您请稍后...</p>\
				<video class="video-js" preload="auto" x-webkit-airplay="true" webkit-playsinline="" x5-video-player-type="h5" x5-video-player-fullscreen="true" playsinline="" width="100%" height="100%" src="' +
				this.hlsUrl + '"></video></div>';
		} else {
			if ((isWeixin || isqq) && isAndroid) {
				this.el.innerHTML =
					'<div class="fullscreen-player-wrap fullscreen-player-wrap-mode1"><div class="fullscreen-play-btn-mode2">\
					<div class="fullscreen-play-btn-mode2-inner">\
						<div class="player_btn_bg_2"></div>\
						<div class="player_btn_mode2_tips">点击观看直播</div>\
					</div>\
				</div>\
				<div class="flv-error-tips" style="display:none">当前flv无法播放,正在帮您切换,请稍等</div>\
				<p class="fullscreen-line-load" style="display:none">当前流不稳定,正在帮您切换线路,请亲们耐心等待...</p>\
				<p class="fullscreen-video-load" style="display:none">视频加载中,您请稍后...</p>\
				<div class="video-control-wrap"><div class="video-control-left-wrap fl"><i class="video-control-play-icon"></i><span class="video-control-play-live">直播</span></div><div class="video-control-right-wrap fr"><span class="auto-change-span" style="display:none">关闭自动切换流</span><span class="change-url-span" style="display:none">' +
					this.watchServer[this.currentHlsIndex].name +
					'</span><i class="fullscreen-icon"></i></div></div>\
				<div class="video-inner-box" style="background: url(' +
					this.liveImg +
					') 50% 50% / cover no-repeat rgb(0, 0, 0);">\
				<video class="video-js" preload="auto" x5-video-player-type="h5" x5-video-player-fullscreen="true" x-webkit-airplay="allow" webkit-playsinline="true" width="100%" height="3000" src="' +
					this.hlsUrl + '" style="object-position:0px 0px;background-size: cover;"></video>\
				</div></div>';
			} else {
				this.el.innerHTML =
					'<div class="fullscreen-player-wrap fullscreen-player-wrap-mode1"><div class="fullscreen-play-btn-mode2">\
					<div class="fullscreen-play-btn-mode2-inner">\
						<div class="player_btn_bg_2"></div>\
						<div class="player_btn_mode2_tips">点击观看直播</div>\
					</div>\
				</div>\
				<div class="flv-error-tips" style="display:none">当前flv无法播放,正在帮您切换,请稍等</div>\
				<p class="fullscreen-line-load" style="display:none">当前流不稳定,正在帮您切换线路,请亲们耐心等待...</p>\
				<p class="fullscreen-video-load" style="display:none">视频加载中,您请稍后...</p>\
				<div class="video-control-wrap"><div class="video-control-left-wrap fl"><i class="video-control-play-icon"></i><span class="video-control-play-live">直播</span></div><div class="video-control-right-wrap fr"><span class="auto-change-span" style="display:none">关闭自动切换流</span><span class="change-url-span" style="display:none">' +
					this.watchServer[this.currentHlsIndex].name +
					'</span><i class="fullscreen-icon"></i></div></div>\
				<div class="video-inner-box" style="background: url(' +
					this.liveImg +
					') 50% 50% / cover no-repeat rgb(0, 0, 0);">\
				<video class="video-js" preload="auto" webkit-playsinline playsinline type="application/x-mpegURL"  width="100%" height="100%" src="' +
					this.hlsUrl + '"></video>\
				</div></div>';
			}
		}
		this.media = document.querySelector(".video-js")
		this.media.controls = false
		//线路切换
		if (this.urlArr.length > 0 && !this.flvSupport) {
			if (this.mode === 0) {
				document.querySelector('.choose-line-innerwrap').style.display = 'block'
				let chooseLineStart =
					'<div class="choose-line-mode0-wrap"><div class="line-wrap">'
				let chooseLineMiddle = ''
				this.watchServer.forEach((item, index) => {
					if (this.currentHlsIndex === index) {
						chooseLineMiddle += '<div class="line-wrap-item active" data-index="' + index + '" data-hls="' + item.hls +
							'">' + item.name + '</div>'
					} else {
						chooseLineMiddle += '<div class="line-wrap-item" data-index="' + index + '" data-hls="' + item.hls + '">' +
							item.name + '</div>'
					}
				})
				let chooseLineEnd = '</div></div>'
				this.el.querySelector('.choose-line-inner-rightwrap').insertAdjacentHTML('beforeEnd', chooseLineStart + chooseLineMiddle + chooseLineEnd)
				document.querySelector('.choose-line-inner-rightwrap').addEventListener("click",()=>{
					if (hasClass(document.querySelector('.choose-line-inner-rightwrap'), 'active')) {
						removeClass(document.querySelector('.choose-line-inner-rightwrap'), 'active')
					} else {
						addClass(document.querySelector('.choose-line-inner-rightwrap'), 'active')
					}
				})
				document.querySelector('.choose-line-mode0-wrap').addEventListener("click", function(e) {
					let target = e.target || e.srcElement
					if ([...target.classList].includes('line-wrap-item')) {
						if (hasClass(target, 'active')) {
							return false
						}
						that.changePlayer(target.dataset.hls, target.dataset.index)
					}
				})
			} else {
				document.querySelector('.change-url-span').style.display = 'inline-block'
				let chooseLineStart =
					'<div class="choose-line-mode2-wrap"><div class="choose-line-mode2-bg-cover"></div><div class="line-wrap">'
				let chooseLineMiddle = ''
				this.watchServer.forEach((item, index) => {
					if (this.currentHlsIndex === index) {
						chooseLineMiddle += '<div class="line-wrap-item active" data-index="' + index + '" data-hls="' + item.hls +
							'">' + item.name + '</div>'
					} else {
						chooseLineMiddle += '<div class="line-wrap-item" data-index="' + index + '" data-hls="' + item.hls + '">' +
							item.name + '</div>'
					}
				})
				let chooseLineEnd = '</div></div>'
				this.el.querySelector('.fullscreen-player-wrap').insertAdjacentHTML('beforeEnd', chooseLineStart + chooseLineMiddle + chooseLineEnd)

				function lineCoverShow() {
					if (hasClass(document.querySelector('.choose-line-mode2-wrap'), 'active')) {
						removeClass(document.querySelector('.choose-line-mode2-wrap'), 'active')
					} else {
						addClass(document.querySelector('.choose-line-mode2-wrap'), 'active')
					}
				}
				document.querySelector('.change-url-span').addEventListener("click", function() {
					lineCoverShow()
				})
				document.querySelector('.choose-line-mode2-bg-cover').addEventListener("click", function() {
					lineCoverShow()
				})
				document.querySelector('.line-wrap').addEventListener("click", function(e) {
					let target = e.target || e.srcElement
					if ([...target.classList].includes('line-wrap-item')) {
						if (hasClass(target, 'active')) {
							return false
						}
						that.changePlayer(target.dataset.hls, target.dataset.index)
						lineCoverShow()
					}
				})
			}
			//需要监听自动切换
			this.emitter.on(playerEvents.SET_PLAYER_INDEX, function(index) {
				if(that.mode !== 0){
					document.querySelector('.change-url-span').innerText = that.watchServer[index].name;
				}else{
					document.querySelector('.choose-line-inner-rightwrap .line-name').innerText = that.watchServer[index].name;
				}
				[...document.querySelectorAll('.line-wrap-item')].forEach((item,elindex) => {
					removeClass(item, 'active')
					if(elindex == index){
						addClass(item, 'active')
					}
				})
			})
		}
		//控制自动切换流按钮显示
		if(isIOS){
			function changeAuto(selector,that){
				if (that.autoChange) {
					that.setAutoChange(false)
					document.querySelector(selector).innerHTML = '开启自动切换流'
				} else {
					that.setAutoChange(true)
					document.querySelector(selector).innerHTML = '关闭自动切换流'
				}
			}
			if(this.mode !== 0){
				document.querySelector('.auto-change-span').style.display = 'inline-block'
				//是否自动切换
				document.querySelector('.auto-change-span').addEventListener("click", function() {
					changeAuto('.auto-change-span',this)
				}.bind(this))
			}else{
				document.querySelector('.set-auto-change-wrap').style.display = 'block'
				document.querySelector('.set-auto-change-wrap').addEventListener("click", function() {
					changeAuto('.mode0-auto-change-span',this)
				}.bind(this))
			}
		}
		//支持flv播放则创建flv播放器
		if(isAndroid && this.flvSupport){
			fullScreenPlayer.flvPlayer = flvCommon.createFlvPlayer(this.hlsUrl, this.media)
			fullScreenPlayer.flvPlayer.on(flv.Events.ERROR, function() {
				document.querySelector('.fullscreen-line-load').style.display = 'none'
				document.querySelector('.fullscreen-video-load').style.display = 'none'
				document.querySelector('.flv-error-tips').style.display = 'block'
				setTimeout(function() {
					that.destroy()
					that.emitter.trigger(playerEvents.FLV_ERROR)
					if (typeof(that.flvErrorCallback) === 'function') {
						that.flvErrorCallback()
					}
				}, 1000)
			})
		}
		//自动播放
		if (this.autoPlay) {
			if(isWeixin || isqq){
				if(isIOS || (isAndroid && this.flvSupport)){
					if (this.mode === 0) {
						document.querySelector('.fullscreen-play-btn').style.display = 'none'
					} else {
						document.querySelector('.fullscreen-play-btn-mode2').style.display = 'none'
					}
				}
				if(isIOS){
					this.play()
				}else if(this.flvSupport && fullScreenPlayer.flvPlayer){
					that.flvPlayerPlay(fullScreenPlayer.flvPlayer)
				}
			}
		}
		//按钮点击播放
		if (this.mode === 0) {
			document.querySelector('.fullscreen-play-btn').addEventListener('click', function() {
				if(document.querySelector('.fullscreen-line-load').style.display === 'block'){
					return false
				}
				this.style.display = 'none'
				if (that.flvSupport && fullScreenPlayer.flvPlayer) {
					that.flvPlayerPlay(fullScreenPlayer.flvPlayer)
				} else {
					that.play()
				}
			})
		} else {
			function mode1Play() {
				if(document.querySelector('.fullscreen-line-load').style.display === 'block'){
					return false
				}
				document.querySelector('.fullscreen-play-btn-mode2').style.display = 'none'
				if (that.flvSupport) {
					that.flvPlayerPlay(fullScreenPlayer.flvPlayer)
				} else {
					that.play()
				}
			}
			document.querySelector('.player_btn_bg_2').addEventListener('click', function() {
				mode1Play()
			})
			document.querySelector('.video-control-play-icon').addEventListener('click', function() {
				mode1Play()
			})
			//安卓微信、QQ浏览器全屏按钮隐藏
			if(isAndroid && isqq || isAndroid && isWeixin){
				document.querySelector('.fullscreen-icon').style.display = 'none'
			}else{
				//点击全屏
				document.querySelector('.fullscreen-icon').addEventListener('click', function() {
					if (this.media.requestFullscreen) {
						this.media.requestFullscreen();
					} else if (this.media.mozRequestFullScreen) {
						this.media.mozRequestFullScreen();
					} else if (this.media.webkitRequestFullScreen) {
						this.media.webkitRequestFullScreen();
					} else if (this.media.webkitEnterFullscreen) {
						this.media.webkitEnterFullscreen();
					}
				}.bind(this))
			}
			document.querySelector('.video-js').addEventListener("click", () => {
				if (fullScreenPlayer.videoControlTimer) {
					clearTimeout(fullScreenPlayer.videoControlTimer)
				}
				if (!hasClass(document.querySelector('.video-control-wrap'), 'active')) {
					addClass(document.querySelector('.video-control-wrap'), 'active')
				} else {
					removeClass(document.querySelector('.video-control-wrap'), 'active')
				}
				if(document.querySelector('.video-control-wrap')){
					fullScreenPlayer.videoControlTimer = setTimeout(() => {
						if(document.querySelector('.video-control-wrap')){
							if (hasClass(document.querySelector('.video-control-wrap'), 'active')) {
								removeClass(document.querySelector('.video-control-wrap'), 'active')
							}
						}
					}, 4000)
				}
			})
		}
		this.media.addEventListener("playing", function() {
			document.querySelector('.fullscreen-video-load').style.display = 'none'
			if (fullScreenPlayer.emptyTime) {
				fullScreenPlayer.fullTime = new Date().getTime();
				var pretime = fullScreenPlayer.fullTime - fullScreenPlayer.emptyTime;
				fullScreenPlayer.totalTime += pretime;
				fullScreenPlayer.emptyTime = 0;
			}
		}.bind(this), false);
		this.media.addEventListener("waiting", function() {
			document.querySelector('.fullscreen-video-load').style.display = 'block'
			fullScreenPlayer.emptyTime = new Date().getTime();
			fullScreenPlayer.fullTime = 0;
		}, false);
		this.media.addEventListener("canplaythrough", function() {
			document.querySelector('.fullscreen-video-load').style.display = 'none'
		}.bind(this), false)
		this.media.addEventListener("play", function() {
			this.media.style.opacity = '1'
			if (this.mode === 0) {
				document.querySelector('.fullscreen-play-btn').style.display = 'none'
			} else {
				document.querySelector('.fullscreen-play-btn-mode2').style.display = 'none'
			}
			that.emitter.trigger(playerEvents.NATIVE_PLAYER_PLAY)
			if (typeof(that.playCallback) === 'function') {
				that.playCallback()
			}
		}.bind(this), false)
		//安卓退出全屏
		this.media.addEventListener('x5videoexitfullscreen', function() {
			if (hasClass(document.querySelector('.video-control-wrap'), 'active')) {
				removeClass(document.querySelector('.video-control-wrap'), 'active')
			}
			document.querySelector('.fullscreen-video-load').style.display = 'none'
			if (this.mode === 0) {
				document.querySelector('.fullscreen-play-btn').style.display = 'block'
			} else {
				document.querySelector('.fullscreen-play-btn-mode2').style.display = 'block'
				document.querySelector('.video-control-play-icon').style.backgroundImage =
					`url(${require('./images/video-control-play.png')})`
			}
		}.bind(this), false)
		//ios退出全屏
		this.media.addEventListener('webkitendfullscreen', function() {
			if (hasClass(document.querySelector('.video-control-wrap'), 'active')) {
				removeClass(document.querySelector('.video-control-wrap'), 'active')
			}
			document.querySelector('.fullscreen-video-load').style.display = 'none'
			if (this.mode === 0) {
				document.querySelector('.fullscreen-play-btn').style.display = 'block'
			} else {
				document.querySelector('.fullscreen-play-btn-mode2').style.display = 'block'
				document.querySelector('.video-control-play-icon').style.backgroundImage =
					`url(${require('./images/video-control-play.png')})`
			}
		}.bind(this), false);
		this.media.addEventListener("pause", function() {
			that.emitter.trigger(playerEvents.NATIVE_PLAYER_PAUSE)
			if (isHuwei && (!isqq || !isWeixin)) {
				document.querySelector('.fullscreen-video-load').style.display = 'none'
				if (this.mode === 0) {
					document.querySelector('.fullscreen-play-btn').style.display = 'block'
				} else {
					if (hasClass(document.querySelector('.video-control-wrap'), 'active')) {
						removeClass(document.querySelector('.video-control-wrap'), 'active')
					}
					this.media.style.opacity = '0'
					if (this.liveImg) {
						document.querySelector('.video-box').style.background = 'url(' + this.liveImg +
							') 50% 50% / cover no-repeat rgb(0, 0, 0);'
					}
					document.querySelector('.fullscreen-play-btn-mode2').style.display = 'block'
				}
			}
		}.bind(this), false)
		this.media.addEventListener("error", function() {}.bind(this), false)
		if (this.sendTime && !this.flvSupport) {
			fullScreenPlayer.sendTimer = setInterval(function() {
				var userAgent = navigator.userAgent;
				var _settime = new Date().getTime();
				if (fullScreenPlayer.emptyTime > 0 && fullScreenPlayer.fullTime == 0) {
					fullScreenPlayer.totalTime = _settime - fullScreenPlayer.emptyTime;
					fullScreenPlayer.emptyTime = _settime;
				}
				if (userAgent.indexOf("Android") < 0)
					this.sendBegainInfo();
				fullScreenPlayer.totalTime = 0
			}.bind(this), this.sendTime * 1000)
		}
	}
	findCurrentUrlIndex(url) {
		let index = this.urlArr.findIndex(item => item === url)
		if (index !== -1) {
			return index
		} else {
			return 0
		}
	}
	play() {
		if(document.querySelector('.fullscreen-line-load').style.display === 'block'){
			return false
		}
		if (this.media.paused) {
			if (this.mode !== 0) {
				document.querySelector('.video-control-play-icon').style.backgroundImage =
					`url(${require('./images/video-control-pause.png')})`
			}
			this.media.playAuto()
		} else {
			document.querySelector('.fullscreen-video-load').style.display = 'none'
			if (this.mode !== 0) {
				document.querySelector('.fullscreen-play-btn-mode2').style.display = 'block'
				document.querySelector('.video-control-play-icon').style.backgroundImage =
					`url(${require('./images/video-control-play.png')})`
				if (hasClass(document.querySelector('.video-control-wrap'), 'active')) {
					removeClass(document.querySelector('.video-control-wrap'), 'active')
				}
			}
			this.pause()
		}
	}
	flvPlayerPlay(){
		let that = this,flvPlayer = fullScreenPlayer.flvPlayer
		if(document.querySelector('.fullscreen-line-load').style.display === 'block'){
			return false
		}
		if(!flvPlayer){
			flvPlayer = fullScreenPlayer.flvPlayer = flvCommon.createFlvPlayer(this.hlsUrl, this.media)
		}
		if (this.media.paused) {
			document.querySelector('.fullscreen-video-load').style.display = 'block'
			flvPlayer.unload()
			flvPlayer.load()
			flvPlayer.play().then(function(){
				if (that.mode !== 0) {
					document.querySelector('.video-control-play-icon').style.backgroundImage =
						`url(${require('./images/video-control-pause.png')})`
				}
				fullScreenPlayer.flvPlayerPlaying = true
				document.querySelector(".fullscreen-video-load").style.display = 'none'	
			}).catch(function(err){
				console.log(err)
			})
		} else {
			document.querySelector('.fullscreen-video-load').style.display = 'none'
			if (this.mode !== 0) {
				document.querySelector('.fullscreen-play-btn-mode2').style.display = 'block'
				document.querySelector('.video-control-play-icon').style.backgroundImage =
					`url(${require('./images/video-control-play.png')})`
				if (hasClass(document.querySelector('.video-control-wrap'), 'active')) {
					removeClass(document.querySelector('.video-control-wrap'), 'active')
				}
			}
			fullScreenPlayer.flvPlayerPlaying = false
			flvCommon.destroyFlvPlayer(fullScreenPlayer.flvPlayer)
			fullScreenPlayer.flvPlayer = null
			that.emitter.trigger(playerEvents.NATIVE_PLAYER_PAUSE)
		}
	}
	pause() {
		if (fullScreenPlayer.flvPlayer) {
			fullScreenPlayer.flvPlayer.pause()
		} else {
			this.media.pause()
		}
	}
	sendBegainInfo() {
		let call_time = new Date().getTime();
		let Fluency = (1 - fullScreenPlayer.totalTime / (this.sendTime * 1000)).toFixed(2);
		//流质量不行,自动切换
		if (Fluency < 0.69 && this.autoChange) {
			if (this.Mictime) {
				//上麦两分钟内不能切换
				let del_time = call_time - this.Mictime;
				if (del_time > 1200) {
					this.currentHlsIndex++;
					if (this.currentHlsIndex >= this.urlArr.length) {
						this.currentHlsIndex = 0;
					}
					document.querySelector('.fullscreen-video-load').style.display = 'none'
					document.querySelector('.fullscreen-line-load').style.display = 'block'
					setTimeout(() => {
						this.changePlayer(this.urlArr[this.currentHlsIndex], this.currentHlsIndex)
					}, 1000)
				} else {
					this.currentHlsIndex = this.currentHlsIndex;
				}
			}
		}
	}
	changePlayer(url, index) {
		fullScreenPlayer.emptyTime = 0
		fullScreenPlayer.fullTime = 0
		fullScreenPlayer.totalTime = 0
		this.currentHlsIndex = index
		this.emitter.trigger(playerEvents.SET_PLAYER_INDEX, this.currentHlsIndex)
		if (this.mode === 0) {
			document.querySelector('.fullscreen-play-btn').style.display = 'none'
		} else {
			document.querySelector('.fullscreen-play-btn-mode2').style.display = 'none'
		}
		document.querySelector('.fullscreen-line-load').style.display = 'none'
		this.media.pause()
		this.media.src = url
		this.play()
	}
	setAutoChange(change) {
		this.autoChange = change
	}
	destroy() {
		if (fullScreenPlayer.flvPlayer) {
			flvCommon.destroyFlvPlayer(fullScreenPlayer.flvPlayer)
		}
		this.media.src = ''
		this.el.innerHTML = ''
		clearInterval(fullScreenPlayer.sendTimer)
		fullScreenPlayer.sendTimer = null
		fullScreenPlayer.flvPlayer = null
		fullScreenPlayer.videoControlTimer = null
		clearTimeout(fullScreenPlayer.videoControlTimer)
	}
	on(event, listener) {
		this.emitter.on(event, listener)
	}
	off(event, listener) {
		this.emitter.off(event, listener)
	}
	set mictime(mictime){
		this.Mictime = mictime
	}
}
